package org.sfx.rich

import javafx.scene.shape.Rectangle
import org.sfx.geometry.Bounds2D
import org.sfx.geometry.Dimensions2D
import org.sfx.geometry.Point2D

class RichRectangle(underlying: Rectangle) {
  def bounds: Bounds2D = Bounds2D(minPoint, dimensions)

  def layoutBounds: Bounds2D = Bounds2D(layoutMinPoint, dimensions)
  
  def layoutMinPoint: Point2D = Point2D(layoutMinX, layoutMinY)
  def layoutMinPoint_=(point: Point2D): Unit = {
    underlying.setLayoutX(point.x)
    underlying.setLayoutY(point.y)
  }
  
  def minPoint: Point2D = Point2D(minX, minY)
  def minPoint_=(point: Point2D): Unit = {
    underlying.setX(point.x)
    underlying.setY(point.y)
  }
  
  def dimensions: Dimensions2D = Dimensions2D(width, height)
  def dimensions_=(dimensions: Dimensions2D): Unit = {
    underlying.setWidth(dimensions.width)
    underlying.setHeight(dimensions.height)
  }
  
  def layoutMinX: Double = underlying.getLayoutX()
  def layoutMinY: Double = underlying.getLayoutY()
  def minX: Double = underlying.getX()
  def minY: Double = underlying.getY()
  def width: Double = underlying.getWidth()
  def height: Double = underlying.getHeight()
      
  def layoutBounds_=(bounds: Bounds2D): Unit = {
    underlying.setLayoutX(bounds.minX)
    underlying.setLayoutY(bounds.minY)
    underlying.setWidth(bounds.width)
    underlying.setHeight(bounds.height)
  }
}
